<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
 pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
 
<!-- This import is necessary for JDBC --> 
<%@ page import="java.sql.*"%> 
<%@ page import="oracle.jdbc.pool.OracleDataSource"%> 
 
<!-- Database lookup --> 
<% 
 Connection conn = null; 
 ResultSet rset = null; 
 String error_msg = ""; 
 try { 
 OracleDataSource ods = new OracleDataSource(); 
 
 ods.setURL("jdbc:oracle:thin:sw2848/abc123@//w4111b.cs.columbia.edu:1521/ADB"); 
 conn = ods.getConnection(); 
 Statement stmt = conn.createStatement(); 
 rset = stmt.executeQuery("select userid, productid, name, price, discount, description from product where userid='" + session.getAttribute("Userid") +"'"); 
 } catch (SQLException e) { 
 error_msg = e.getMessage(); 
 if( conn != null ) { 
 conn.close(); 
 } 
 } 
%> 
 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Products</title> 
</head> 
<body> 
 <H2>Products</H2> 
 
 <hr noshade size=7 color=blue>
<button type="button">Add</button>
<input type="button" title="WARNING"value="Professor" id="pro">
 <TABLE> 
 <tr> 
 <td>Purchased_By</td><td>productID</td><td>name</td><td>price</td><td>discount</td><td>description</td>
 </tr> 
 <tr> 
 <td><b>----------</b></td><td><b>----------</b></td><td><b>----------</b></td><td><b>----------</b></td><td><b>----------</b></td>
 </tr>
 <% 
 if(rset != null) { 
 while(rset.next()) { 
 out.print("<tr>"); 
 out.print("<td>" + rset.getInt("userid") + "</td><td>" + 
rset.getInt("productid") + "</td>" + 
 "<td>" + rset.getString("name") + "</td><td>" + 
		 rset.getFloat("price") + "</td><td>" + rset.getFloat("discount") + "</td><td>" + rset.getString("description")); 
 
 out.print("</tr>"); 
 
 } 
 } else { 
 out.print(error_msg); 
 } 
 if( conn != null ) { 
 conn.close(); 
 } 
 %> 
 </TABLE> 
 <form action = "DeleteProduct" method ="post" >
 <label >Product ID to be delete: </label>
<input id="Productid" name="Productid">
  <button type="submit">Delete</button>
 </form>
 
 <form action = "AddProduct" method ="post">
 <div class="ui small form segment" style="height:500px; width:700px" >   
    <div class="two fields">
      <div class="field">
        <label for="Productname">Product Name</label>
        <input id="Productname" name = "Productname" placeholder="Productname" type="text" />
      </div>

      <div class="field">
        <label for="Description">Description</label>
        <input id="Description" name = "Description"placeholder="Description" type="text">
      </div>
    </div>

    <div class="field">
      <label for="Price">Price:</label>
      <input id="Price" name="Price"placeholder="Price" type="text">
    </div>

    <div class="field">
      <label for="Discount">Discount:</label>
      <input id="Discount" name="Discount" placeholder="discount" type="text">
    </div>
 <div class="field">
      <label for="Imgpath">Image Path:</label>
      <input id="Imgpath" name="Imgpath" placeholder="Imgpath" type="text">
    </div>
 
 <button type="submit">Add</button>
 </form>



</body> 
</html>